<?php
/**
 * Created by PhpStorm.
 * User: liyang
 * Date: 19-3-15
 * Time: 上午10:57
 */
//正式域名 https://5gm.wanyuenet.com 顾客端/店铺端/业务员端/管理后台：5g  5gs  5gb  5gm
//后台管理
use Illuminate\Routing\Router;
use App\Http\Controllers\Admin\LoginController;
use App\Http\Controllers\Admin\AdminController;
use  App\Http\Controllers\Admin\IndexController;
use App\Http\Controllers\Admin\MenuController;
use App\Http\Controllers\Admin\PermissionsController;
use App\Http\Controllers\Admin\RolesController;
use App\Http\Controllers\Admin\TeamController;
use App\Http\Controllers\Admin\NewsController;
use App\Http\Controllers\Admin\ReportController;
use App\Http\Controllers\Admin\UserController;
Route::group(['prefix' => 'admin', 'namespace' => 'Admin'], function() {

    Route::get('auth/check', function() {
        if (!optional(auth()->guard('admin')->user())->id and !optional(auth()->guard('manager')->user())->id) {
            return sprintf('parent.window.location.href="%s"', url('admin/login'));
        }
        return '';
    });

    Route::group(['middleware' =>'auth.admin'], function() {
        //退出
        Route::get('logout', [LoginController::class,'logout']);
        Route::post('logout', [LoginController::class,'logout']);


        //首页
        Route::get('/', [IndexController::class,'index'])->name('admin.index');
        Route::get('/index', [IndexController::class,'index']);
        Route::get('welcome', [IndexController::class,'welcome'])->name('admin.welcome');
        Route::get('test', [IndexController::class,'test']);
        Route::get('send_point', [IndexController::class,'sendPoint']);
        Route::post('user/login',[IndexController::class,'UserLogin']);
    });

    Route::get('login', [LoginController::class,'showLoginForm'])->name('admin.login');
    Route::get('channel_login', [LoginController::class,'showFLoginForm'])->name('admin.flogin');
    Route::post('login', [LoginController::class,'login']);

    Route::group(['prefix' => 'api', 'middleware' => 'auth.admin'], function () {
        Route::get('menu/list', [MenuController::class,'apiList']);
        Route::get('menu/table_list', [MenuController::class,'apiTableList']);
        Route::post('menu/delete', [MenuController::class,'delete']);
        Route::post('team/apilist', [TeamController::class,'apiList']);
        Route::get('news/apiList', [NewsController::class,'apiList']);
        Route::get('news/newsApiList', [NewsController::class,'newApiList']);

        Route::post('news/create-api', [NewsController::class,'createApi']);

        Route::post('news/delete', [NewsController::class,'delete']);
        Route::get('report/apiList', [ReportController::class,'apiList']);
        Route::get('report/select_list', [ReportController::class,'selectList']);
        Route::get('report/user/apiList', [ReportController::class,'userList']);
        Route::post('report/user/create-api', [ReportController::class,'userApiCreate']);
        Route::post('report/user-del-api', [ReportController::class,'userDel']);
        Route::post('report/authDelete', [ReportController::class,'authDelete']);
        Route::post('report/create-api', [ReportController::class,'createApi']);
        Route::post('report/delete', [ReportController::class,'delete']);
        //团队信息

        Route::get('team/user/apiList', [TeamController::class,'teamList']);
        Route::post('team/user/create-api', [TeamController::class,'teamCreateApi']);
        Route::post('team/authDelete', [TeamController::class,'authDelete']);
        Route::post('team/create-api', [TeamController::class,'createApi']);
        Route::get('team/apiList', [TeamController::class,'apiList']);

        Route::post('team/delete', [TeamController::class,'delete']);
        Route::post('team/user-del-api', [TeamController::class,'userDel']);
        Route::get('user/apiList',[UserController::class,'apiList']);
        Route::post('user/Unbound',[UserController::class,'Unbound']);

        Route::get('send/machine',[NewsController::class,'SendApiList']);
        Route::post('send/create-api', [NewsController::class,'SendcreateApi']);
        Route::post('send/apidelete', [NewsController::class,'SenddelApi']);

        //素材管理
        Route::get('apiMaterial',[NewsController::class,'apiMaterial']);
        Route::post('material/create-api', [NewsController::class,'MaterialApicreate']);

        Route::post('material/upload', [NewsController::class,'Upload']);
        Route::post('material/DelUpload', [NewsController::class,'UploadDel']);
        Route::post('material/delete', [NewsController::class,'MaterialDel']);

        //推送消息记录
        Route::get('robotMsgApi',[NewsController::class,'RobotMsgApi']);
        Route::post('robotMsg/delete', [NewsController::class,'robotMsgDel']);
        Route::get('config/apiList',[\App\Http\Controllers\Admin\ConfigController::class,'apiList']);
        Route::match(['post'],'config/create',[\App\Http\Controllers\Admin\ConfigController::class,'create']);
        Route::post('config/delete',[\App\Http\Controllers\Admin\ConfigController::class,'delete']);
        Route::get('new/send/machineApi',[NewsController::class,'SendMachineApi']);
        Route::post('news/SendMachine/create-api',[NewsController::class,'SendMachineCreate']);
        Route::post('news/SendMachine/delete-api', [NewsController::class,'SendMachineDel']);

        Route::get('user/select', [UserController::class,'selectList']);

        Route::get('user/select/apilist',[UserController::class,'apiSelectList']);
        Route::post('user/UserPmsCreate',[UserController::class,'pmsCreate']);
    });



        Route::middleware('permissions.check')->group(function() {
        Route::get('admin/index', [AdminController::class,'index']);
        Route::match(['get', 'post'], 'admin/create', [AdminController::class,'create']);
        Route::match(['get', 'post'], 'admin/relate/{id}', [AdminController::class,'relate']);
        Route::match(['get', 'post'], 'admin/city/{id}', [AdminController::class,'city']);
        Route::match(['get', 'post'], 'admin/update/{id}', [AdminController::class,'update']);
        Route::match(['get', 'post'], 'admin/resetPassword', [AdminController::class,'resetPassword']);
        Route::post('admin/destroy/{id}', [AdminController::class,'destroy']);
            Route::get('permissions/index', [PermissionsController::class,'index']);
            Route::get('permissions/tree', [PermissionsController::class,'tree']);
            //目录结构
            Route::get('menu', [MenuController::class,'index']);
            Route::get('menu/create', [MenuController::class,'create']);
            Route::post('menu/store', [MenuController::class,'store']);
            Route::get('menu/edit/{id}', [MenuController::class,'edit']);
            Route::post('menu/update/{id}', [MenuController::class,'update']);
            //角色配置
            Route::get('roles/index', [RolesController::class,'index']);
            Route::match(['get', 'post'], 'roles/create', [RolesController::class,'create']);
            Route::match(['get', 'post'], 'roles/relate/{id}', [RolesController::class,'relate']);
            Route::match(['get', 'post'], 'roles/update/{id}', [RolesController::class,'update']);
            Route::post('roles/enable', [RolesController::class,'enable']);
            Route::post('roles/disable', [RolesController::class,'disable']);

            Route::get('team/index', [TeamController::class,'index']);
            //消息管理
            Route::get('news/index', [NewsController::class,'index']);
            Route::get('news/list', [NewsController::class,'newsList']);
            //消息管理添加
            Route::get('news/edit/{id}', [NewsController::class,'edit']);
            Route::get('news/create', [NewsController::class,'create']);

            //报表管理
            Route::get('report/list', [ReportController::class,'index']);
            //报表管理
            Route::get('report/create', [ReportController::class,'create']);
            Route::get('report/auth', [ReportController::class,'auth']);


            //团队添加
            Route::get('team/create', [TeamController::class,'create']);
            Route::get('team/auth', [TeamController::class,'auth']);

            //用户管理
            Route::get('user/list', [UserController::class,'index']);



            //机器人消息列表

            Route::get('send/msg', [NewsController::class,'SendingMsg']);

            Route::get('send/sendedit/{id}', [NewsController::class,'SendApiedit']);
            Route::get('send/sendcreate', [NewsController::class,'SendApicreate']);

            //素材管理
            Route::get('material/index', [NewsController::class,'Material']);
            Route::get('material/create', [NewsController::class,'MaterialApicreate']);
            Route::get('material/edit/{id}', [NewsController::class,'MaterialApiedit']);

            //推送消息记录
            Route::get('robotmsg/index', [NewsController::class,'RobotMsg']);

            //配置中心
            Route::get('config/list',[\App\Http\Controllers\Admin\ConfigController::class,'index']);
            Route::match(['get'],'config/create',[\App\Http\Controllers\Admin\ConfigController::class,'create']);
            Route::get('config/edit/{id}',[\App\Http\Controllers\Admin\ConfigController::class,'edit']);

            Route::get('new/send/machine',[NewsController::class,'SendMachine']);
            Route::get('news/SendMachine/create-api',[NewsController::class,'SendMachineCreate']);
            Route::get('news/SendMachine/update-api/{id}',[NewsController::class,'SendMachineUpdate']);


        });

});
